package com.boyon.system.action;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.boyon.system.domain.Verification;
import com.boyon.system.service.VerificationService;
import com.boyon.web.param.annotation.ValidatorRequestBody;
import com.boyon.web.response.SuccessResponse;

import lombok.extern.slf4j.Slf4j;

/**
 * ClassName:VerificationAction <br/>
 * Function: 验证码图片请求action. <br/>
 * Date: 2018年3月17日 下午9:35:04 <br/>
 * 
 * @author sunshulin
 * @version
 * @since JDK 1.8
 * @see
 */
@Controller
@RequestMapping(value = "/beyon", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Slf4j
public class VerificationAction {

	@Autowired
	private VerificationService verificationService;

	/**
	 * 
	 * createVerification:生成验证码图片. <br/>
	 * 
	 * @author sunshulin
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value = "/verification")
	@ResponseBody
	public SuccessResponse verification(@ValidatorRequestBody Verification verification, HttpSession session) {
		log.info("boyon verification unique={}", verification.getUnique());
		log.info("boyon verification sessionId={}", session.getId());
		return new SuccessResponse(verificationService.createVerification(175, 36, 4,
				verification.getUnique()));
	}
}
